// 试卷分类
export class QuestionClassify {
  static className: string = "question_classify" // 表名
  id: number | null = null
  title: string = ""
  num: number = 0
  image_url: string = ""
  remark: string = ""
  is_del: boolean = false
}

// 试卷
export class QuestionPaper {
  static className: string = "question_paper"
  id: number | null = null
  classify_id: number = 0
  title: string = ""
  level: string = ""
  order: number = 0
  remark: string = ""
  done_id: string = ''
}

export class QuestionPaperList extends QuestionPaper {
  listLength: number = 0

  constructor(obj: QuestionPaper, listLength: number) {
    super()
    this.listLength = listLength
    this.id = obj.id
    this.classify_id = obj.classify_id
    this.title = obj.title
    this.level = obj.level
    this.order = obj.order
    this.remark = obj.remark
    this.done_id = obj.done_id
  }
}


// 试题详情
export class QuestionInfo {
  static className: string = "question_info"
  id: number | null = null
  classify_id: number = 0
  paper_id: number = 0
  title: string = ""
  order: number = 0
  question_type: string = ""
  answer_letter: string = ""
  right_answer_letter: string = ""
  answer_text: string = ""
  answer_solution: string = ""
}

// 试卷用户回答
export class QuestionUserAll {
  static className: string = "question_user_all"
  id: number | null = null
  classify_id: number = 0
  paper_id: number = 0
  is_done: boolean = false
  score: number = 0
  start_time: Date = new Date()
  end_time: Date = new Date()
  user_id: string = ""
  remark: string = ""
}

// 用户积分记录
export class ScoreUserAll {
  static className: string = "score_user_all"
  id: number | null = null
  classify_id: number = 0
  paper_id: number = 0
  is_add: boolean = true
  score: number = 0
  create_time: Date = new Date()
  user_id: string = ""
}

// 用户回答的每个题目的详情
export class QuestionUserAnswer {
  static className: string = "question_user_answer"
  id: number | null = null
  classify_id: number = 0
  question_info_id: number = 0
  paper_id: number = 0
  is_right: boolean = false
  answer_time: Date = new Date()
  user_id: string = ""
  user_answer: string = ""
}

// 错题集表
export class QuestionWrong {
  static className: string = "question_wrong"
  id: number | null = null
  question_info_id: number = 0
  classify_id: number = 0
  user_answer: string = ""
  paper_id: number = 0
  user_id: string = ""
  answer_time: Date = new Date()
  is_right: boolean = false
}


// 用户信息
export class UserInfo {
  static className: string = "user_info"
  id: number | null = null
  avatar: string = ""
  nick_name: string = ""
  user_id: string = ""
  is_admin: boolean = false
  account: string = ""
  password: string = ""
  like_id: string = ""
  collect_id: string = ""
  view_id: string = ''
  back_image: string = ''
  wrong_id: string = ''
}

// 管理员信息
export class AdminInfo {
  static className: string = "admin_info"
  id: number | null = null
  adminId: string = ""
  adminName: string = ""
  password: string = ""
  stop_service: boolean = false
}

export interface PreAdminInfo {
  id: number | null
  adminId: string
  adminName: string
  password: string
  timestamp: number
  stop_service: boolean
}

// 题库类型
export class QuestionBankType {
  static className: string = "question_view_classify"
  id: number | null = null
  classifyName: string = ""
  typeNUm: number = 0
}

// 浏览题目详情
@Observed
export class QuestionViewInfo {
  static className: string = "question_view_info"
  id: number | null = null
  title: string = ''
  type: number = 0
  level: number = 0
  content: string = ''
  view_count: number = 0
  like_count: number = 0
}

// 消息通知
export class Message {
  static className: string = "message"
  id: number | null = null
  message_type: number = 0
  title: string = ''
  content: string = ""
  create_time: string = ''
  read_id: string = ''
  send_id: string = ''
  accept_id: string = ''
}

// 用户积分表
export class UserScore {
  static className: string = "user_score"
  id: number | null = null
  userId: string = ""
  score: number = 0
}

export class UserScoreDisplay extends UserScore {
  avatar: string = ""
  nick_name: string = ""

  constructor(obj: UserScore, avatar: string, nick_name: string) {
    super()
    this.avatar = avatar
    this.nick_name = nick_name
    this.id = obj.id
    this.userId = obj.userId
    this.score = obj.score
  }
}


export class QuestionScoreDisplay extends QuestionUserAll {
  avatar: string = ""
  nick_name: string = ""

  constructor(obj: QuestionUserAll, avatar: string, nick_name: string) {
    super()
    this.avatar = avatar
    this.nick_name = nick_name
    this.id = obj.id
    this.classify_id = obj.classify_id
    this.paper_id = obj.paper_id
    this.user_id = obj.user_id
    this.is_done = obj.is_done
    this.start_time = obj.start_time
    this.end_time = obj.end_time
    this.remark = obj.remark
    this.score = obj.score
  }
}

export class UserCollect {
  all_people: number = 0
  all_wrong: number = 0
}


export interface AnswerItem {
  letter: string // 选项的标识
  select: boolean // 是否被选择
  letter_text: string // 选项和标识的组合
}

//
export enum QuestionTypeEnum {
  Judge = "1", // 判断
  Single = "2", // 单选
  Multi = "3" // 多选
}

@Observed
export class AnswerItemModel implements AnswerItem {
  letter: string = ''
  select: boolean = false
  letter_text: string = ''

  constructor(model: AnswerItem) {
    this.letter = model.letter
    this.select = model.select
    this.letter_text = model.letter_text
  }
}

